服务
提示
本文所介绍的 OpenAPI 适用于 K8s YAML 服务。
# 获取服务列表
# 测试服务
请求
GET /openapi/service/yaml/services?projectKey=<项目标识>
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
service_name | string | 服务名称 |
type | string | 服务类型,固定值 k8s |
containers | []Container | 服务组件列表 |
Container 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
name | string | 服务组件名称 |
image | string | 服务组件的镜像信息 |
image_name | string | 服务组件的镜像名称 |
返回示例
点击查看
{
"service": [
{
"service_name": "service-1",
"type": "k8s",
"containers": [
{
"name": "myapp-1",
"image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:v0.1__linux_amd64",
"image_name": "myapp-1"
}
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 生产服务
请求
GET /openapi/service/yaml/production/services?projectKey=<项目标识>
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
service_name | string | 服务名称 |
type | string | 服务类型,固定值 k8s |
containers | []Container | 服务组件列表 |
Container
| 参数名 | 类型 | 描述 |
|---|---|---|
name | string | 服务组件名称 |
image | string | 服务组件的镜像信息 |
image_name | string | 服务组件的镜像名称 |
返回示例
点击查看
[
{
"service_name": "service-1",
"type": "k8s",
"containers": [
{
"name": "myapp-1",
"image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:v0.1__linux_amd64",
"image_name": "myapp-1"
}
]
}
]
2
3
4
5
6
7
8
9
10
11
12
13
# 获取服务详情
# 测试服务
请求
GET /openapi/service/yaml/:serviceName?projectKey=<项目标识>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
service_name | string | 服务名称 |
created_by | string | 服务创建者 |
created_time | int | 服务创建时间 |
type | string | 服务类型,固定为 k8s |
containers | []Container | 服务组件列表 |
service_variable_kvs | []KeyVal | 服务变量列表 |
yaml | string | 服务配置的 YAML 内容 |
Container 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
name | string | 服务组件名称 |
image | string | 服务组件的镜像信息 |
image_name | string | 服务组件的镜像名称 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
返回示例
点击查看
{
"service_name": "service2",
"type": "k8s",
"created_by": "admin",
"created_time": 1689660993,
"yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service2\n labels: \n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: test\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: {{.world}}\n spec:\n containers:\n - name: service2\n image: koderover.******.com/koderover-demo/service2:latest\n imagePullPolicy: Always \n command:\n - /workspace/service2\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service2\n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}",
"containers": [
{
"name": "service2",
"image": "koderover.******.com/koderover-demo/service2:latest",
"image_name": "service2"
}
],
"service_variable_kvs": [
{
"key": "cpuLimit",
"value": "55m",
"type": "string",
"options": [],
"desc": ""
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 生产服务
请求
GET /openapi/service/yaml/production/:serviceName?projectKey=<项目标识>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
service_name | string | 服务名称 |
created_by | string | 服务创建者 |
created_time | int | 服务创建时间 |
type | string | 服务类型,固定为 k8s |
containers | []Container | 服务组件列表 |
service_variable_kvs | []KeyVal | 服务变量列表 |
yaml | string | 服务配置的 YAML 内容 |
Container 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
name | string | 服务组件名称 |
image | string | 服务组件的镜像信息 |
image_name | string | 服务组件的镜像名称 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
返回示例
点击查看
{
"service_name": "service2",
"type": "k8s",
"created_by": "admin",
"created_time": 1689660993,
"yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service2\n labels: \n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: test\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: {{.world}}\n spec:\n containers:\n - name: service2\n image: koderover.******.com/koderover-demo/service2:latest\n imagePullPolicy: Always \n command:\n - /workspace/service2\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service2\n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}",
"containers": [
{
"name": "service2",
"image": "koderover.******.com/koderover-demo/service2:latest",
"image_name": "service2"
}
],
"service_variable_kvs": [
{
"key": "cpuLimit",
"value": "55m",
"type": "string",
"options": [],
"desc": ""
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 获取服务标签
请求
GET /openapi/service/yaml/:serviceName/labels?projectKey=<项目标识>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回实例
正确时返回
[
{
"key": "key",
"value": "value"
},
...
]
2
3
4
5
6
7
错误时返回
{
"code": 500,
"description": "...",
"message": "Internal Error"
}
2
3
4
5
# 使用模板新建服务
# 测试服务
请求
POST /openapi/service/template/load/yaml
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_name | 服务名称 | string | 是 |
project_key | 项目标识 | string | 是 |
template_name | K8s Yaml 模板名称 | string | 是 |
auto_sync | 自动同步开关 | bool | 否 |
variable_yaml | 模板中的变量信息 | []KeyVal | 否 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
Body 参数示例
使用模板 microservice-template 为项目 demo 新建服务 service1:
点击查看
{
"service_name": "service1",
"project_key":"demo",
"template_name": "microservice-template",
"auto_sync": true,
"variable_yaml": [
{
"key": "cpuLimit",
"value": "100m"
},
{
"key": "memoryLimit",
"value": "100Mi"
},
{
"key": "port",
"value": "20221"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
返回
{
"message": "success"
}
2
3
# 生产服务
请求
POST /openapi/service/template/production/load/yaml
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_name | 服务名称 | string | 是 |
yaml | 服务的 YAML 内容 | string | 是 |
project_key | 项目标识 | string | 是 |
template_name | K8s Yaml 模板名称 | string | 是 |
auto_sync | 自动同步开关 | bool | 否 |
variable_yaml | 模板中的变量信息 | []KeyVal | 否 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
Body 参数示例
使用模板 base-template 为项目 demo 新建服务 service1:
点击查看
{
"service_name": "service1",
"production":true,
"project_key":"demo",
"template_name":"base-template",
"auto_sync":true,
"variable_yaml":[
{
"key":"cpuLimit",
"value":"15m"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
返回
{
"message": "success"
}
2
3
# 手动输入新建服务
# 测试服务
请求
POST /openapi/service/yaml/raw?projectKey=<项目标识>
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_name | 服务名称 | string | 是 |
yaml | 服务的 YAML 内容 | string | 是 |
variable_yaml | yaml中的变量信息 | []KeyVal | 否 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
Body 参数示例
点击查看
{
"service_name":"service-3",
"yaml":"apiVersion: v1\nkind: Service\nmetadata:\n name: a\n labels:\n app: a\nspec:\n ports:\n - name: http\n port: 80\n targetPort: 8080\n selector:\n app: a\n\n---\n\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: a\n labels:\n app: a\nspec:\n selector:\n matchLabels:\n app: a\n replicas: 1\n template:\n metadata:\n labels:\n app: a\n spec:\n containers:\n - name: myapp-1\n image: koderover.******.com/koderover-demo/myapp-1:v0.1__linux_amd64\n imagePullPolicy: Always\n command: [\"/myapp-1\"]\n args: [\"--downstream-addr\", \"$(DOWNSTREAM_ADDR)\", \"--headers\", \"$(HEADERS)\"]\n env:\n - name: DOWNSTREAM_ADDR\n value: \"b\"\n - name: HEADERS\n value: \"x-request-id\"\n ports:\n - containerPort: 8080\n resources:\n limits:\n cpu: {{.cpu}}\n memory: 122Mi\n",
"variable_yaml":[
{
"key":"cpu",
"value":"12m",
"desc":"cpu值",
"type":"string"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
返回
{
"message": "success"
}
2
3
# 生产服务
请求
POST /openapi/service/yaml/production/raw?projectKey=<项目标识>
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_name | 服务名称 | string | 是 |
yaml | 服务的 YAML 内容 | string | 是 |
variable_yaml | yaml中的变量信息 | []KeyVal | 否 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
Body 参数示例
点击查看
{
"service_name":"service-3",
"yaml":"apiVersion: v1\nkind: Service\nmetadata:\n name: a\n labels:\n app: a\nspec:\n ports:\n - name: http\n port: 80\n targetPort: 8080\n selector:\n app: a\n\n---\n\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: a\n labels:\n app: a\nspec:\n selector:\n matchLabels:\n app: a\n replicas: 1\n template:\n metadata:\n labels:\n app: a\n spec:\n containers:\n - name: myapp-1\n image: koderover.******.com/koderover-demo/myapp-1:v0.1__linux_amd64\n imagePullPolicy: Always\n command: [\"/myapp-1\"]\n args: [\"--downstream-addr\", \"$(DOWNSTREAM_ADDR)\", \"--headers\", \"$(HEADERS)\"]\n env:\n - name: DOWNSTREAM_ADDR\n value: \"b\"\n - name: HEADERS\n value: \"x-request-id\"\n ports:\n - containerPort: 8080\n resources:\n limits:\n cpu: {{.cpu}}\n memory: 122Mi\n",
"variable_yaml":[
{
"key":"cpu",
"value":"12m",
"desc":"cpu值",
"type":"string"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
返回
{
"message": "success"
}
2
3
# 从代码库新建 K8s YAML 服务
请求
POST /openapi/service/loader/load?codehostName=<代码源名称>&repoName=<代码库名称>&branchName=<分支名称>&remoteName=<远端名称>&repoOwner=<仓库拥有者>&namespace=<仓库命名空间>&production=<是否生产服务>
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
codehostName | string | 代码源名称 | 是 |
repoName | string | 代码库名称 | 是 |
branchName | string | 服务配置所在分支 | 是 |
remoteName | string | Git 远端名称,Gerrit、Gitee 和 Gitee Enterprise 场景使用;为空默认为 origin | 否 |
repoOwner | string | 仓库拥有者/组织名 | 是 |
namespace | string | GitHub/GitLab 仓库命名空间,为空默认使用 repoOwner | 否 |
production | bool | 是否创建生产服务,仅值为 true 时创建生产服务,默认为 false | 否 |
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
product_name | 项目标识 | string | 是 |
service_paths | 服务路径列表 | []LoadServicePath | 是 |
LoadServicePath 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_name | 服务名称 | string | 是 |
path | 服务配置文件或目录在代码库中的相对路径;is_dir 为 true 时可传空字符串表示仓库根目录 | string | 条件必填 |
is_dir | 是否为目录,true 表示从目录加载,false 表示从单个 YAML 文件加载,默认为 false | bool | 否 |
请求示例
从代码源 github-demo 的 main 分支为项目 demo 新建测试服务:
POST /openapi/service/loader/load?codehostName=github-demo&repoName=demo&branchName=main&repoOwner=koderover&production=false
Body 参数示例
点击查看
{
"product_name": "demo",
"service_paths": [
{
"service_name": "backend",
"path": "services/backend/deployment.yaml",
"is_dir": false
}
]
}
2
3
4
5
6
7
8
9
10
返回
{
"message": "success"
}
2
3
# 从代码仓新建 Helm 服务
支持从代码库、公开代码库和 Chart 仓库新建 Helm 服务。
请求
POST /openapi/service/helm/load?projectKey=<项目标识>
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
source | 服务来源枚举,取值及含义见下表 | string | 是 |
production | 是否创建生产服务,默认为 false | bool | 否 |
createFrom | 服务来源配置,不同 source 对应字段见下方说明 | object | 是 |
source 取值说明
| 取值 | 含义 |
|---|---|
repo | 已接入的 GitHub、GitLab 或 other 类型通用 Git 代码源 |
gerrit | 已接入的 Gerrit 代码源 |
gitee | 已接入的 Gitee 代码源 |
gitee-enterprise | 已接入的 Gitee Enterprise 代码源 |
publicRepo | 公开 GitHub 代码库 |
chartRepo | 已接入的 Chart 仓库 |
source 为已接入代码源时 createFrom 参数说明
适用于 repo、gerrit、gitee 和 gitee-enterprise。
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
codehostName | 代码源名称 | string | 是 |
owner | 仓库拥有者/组织名 | string | 是 |
namespace | 仓库命名空间,GitLab 多层 group 时使用;为空默认使用 owner | string | 否 |
repo | 代码库名称 | string | 是 |
branch | 分支名称 | string | 是 |
paths | Chart 所在路径列表,支持传多个路径 | []string | 是 |
source 为 publicRepo 时 createFrom 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
repoLink | 公开仓库地址 | string | 是 |
paths | Chart 所在路径列表,支持传多个路径 | []string | 是 |
source 为 chartRepo 时 createFrom 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
chartRepoName | Chart 仓库名称 | string | 是 |
chartName | Chart 名称 | string | 是 |
chartVersion | Chart 版本约束;为空时不指定版本,由 Helm 解析可用版本 | string | 否 |
Body 参数示例
从代码源 github-demo 的 main 分支为项目 demo 新建 Helm 服务:
点击查看
{
"source": "repo",
"production": false,
"createFrom": {
"codehostName": "github-demo",
"owner": "koderover",
"repo": "helm-charts",
"branch": "main",
"paths": [
"charts/backend"
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
返回参数说明
| 参数名 | 说明 | 类型 |
|---|---|---|
successServices | 创建成功的服务名称列表 | []string |
failedServices | 创建失败的服务列表 | []FailedHelmService |
FailedHelmService 参数说明
| 参数名 | 说明 | 类型 |
|---|---|---|
path | 创建失败的 Chart 路径 | string |
error | 失败原因 | string |
返回示例
点击查看
{
"successServices": [
"backend"
],
"failedServices": []
}
2
3
4
5
6
# 更新服务配置
# 测试服务
# 请求
PUT /openapi/service/yaml/:serviceName?projectKey=<project_name>
# 路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
# Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
# Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
type | 服务类型,指定为 k8s | string | 是 |
yaml | 服务配置的 YAML 内容 | string | 是 |
Body 参数示例
点击查看
{
"type":"k8s",
"yaml":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service1\n labels: \n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n spec:\n containers:\n - name: service1\n image: koderover.******.com/koderover-demo/service1:latest\n imagePullPolicy: Always \n command:\n - /workspace/service1\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service1\n labels:\n app.kubernetes.io/name: yaml-poc\n app.kubernetes.io/instance: service1\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}\n",
}
2
3
4
# 返回
{
"message": "success"
}
2
3
# 生产服务
请求
PUT /openapi/service/yaml/production/:serviceName?projectKey=<project_name>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
type | 服务类型,指定为 k8s | string | 是 |
yaml | 服务配置的 YAML 内容 | string | 是 |
Body 参数示例
点击查看
{
"type":"k8s",
"yaml":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service1\n labels: \n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n spec:\n containers:\n - name: service1\n image: koderover.******.com/koderover-demo/service1:latest\n imagePullPolicy: Always \n command:\n - /workspace/service1\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service1\n labels:\n app.kubernetes.io/name: yaml-poc\n app.kubernetes.io/instance: service1\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}\n",
}
2
3
4
返回
{
"message": "success"
}
2
3
# 更新服务变量
# 测试服务
请求
PUT /openapi/service/yaml/:serviceName/variable?projectKey=<projectKey>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_variable_kvs | 服务变量列表 | []KeyVal | 是 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
Body 参数示例
点击查看
{
"service_variable_kvs": [
{
"key":"cpu",
"value":"12m",
"type":"string",
"options":[],
"desc":""
}
]
}
2
3
4
5
6
7
8
9
10
11
返回
{
"message": "success"
}
2
3
# 生产服务
请求
PUT /openapi/service/yaml/production/:serviceName/variable?projectKey=<projectKey>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_variable_kvs | 服务变量列表 | []KeyVal | 是 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
type | 变量值的类型,有四种类型:bool、string、enum、yaml | string | 是 |
options | 变量可选值列表,当 type 为 enum 时该字段有意义 | []string | 否 |
desc | 变量描述信息 | String | 否 |
Body 参数示例
点击查看
{
"service_variable_kvs": [
{
"key":"cpu",
"value":"12m",
"type":"string",
"options":[],
"desc":""
}
]
}
2
3
4
5
6
7
8
9
10
11
返回
{
"message": "success"
}
2
3
# 删除服务
# 测试服务
# 请求
DELETE /openapi/service/yaml/<服务名称>?projectKey=<项目标识>
# 返回
{
"message": "success"
}
2
3
# 生产服务
请求
DELETE /openapi/service/yaml/production/:serviceName?projectKey=<项目标识>
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
serviceName | string | 服务名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
返回
{
"message": "success"
}
2
3
# 使用模板新建 Helm 服务
请求
POST /openapi/service/template/load/helm?projectKey=<projectKey>
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
project_key | 项目标识 | string | 是 |
service_name | 服务名称 | string | 是 |
production | 是否生产环境 | bool | 否 |
template_name | Helm 模板名称 | string | 是 |
values_yaml | values yaml 内容 | string | 否 |
variables | 模板中的变量信息 | []KeyVal | 否 |
auto_sync | 自动同步开关 | bool | 否 |
KeyVal 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
value | 变量的值,若有嵌套值,使用 json 格式 | any | 是 |
Body 参数示例
使用模板 general-chart 为项目 multi-chart 新建服务 api-test:
点击查看
{
"auto_sync": true,
"production": false,
"project_key": "multi-chart",
"service_name": "api-test",
"template_name": "general-chart",
"values_yaml": "aa: bb\ncc: dd",
"variables": [
{
"key": "port",
"value": 20012
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
返回
{
"message": "success"
}
2
3


